feat(react): add events to react generated components#371
Merged
Conversation
mimshins
requested changes
Mar 5, 2025
| elementClass: ComponentNamespace.TapsiPinwheel, | ||
| react: React, | ||
| events: {}, | ||
| events: { onChange: "change" }, |
Collaborator
There was a problem hiding this comment.
Remove the redundant events.
|
|
||
| const cem = await generateCem(); | ||
|
|
||
| const sidebarItemsMap: Record<string, DefaultTheme.SidebarItem> = {}; |
Collaborator
There was a problem hiding this comment.
Encapsulate the following codes within its separated function.
scripts/generate-metadata.ts
Outdated
| "./packages/web-components/src", | ||
| ); | ||
|
|
||
| const distDir = path.relative(cwd(), path.join(workspaceDir, "dist")); |
Collaborator
There was a problem hiding this comment.
- Remove
cwd. - Rename
workspaceDirtopackageDir.
Comment on lines
4
to
9
| type Declaration, | ||
| type Package, | ||
| } from "custom-elements-manifest"; | ||
| import { exec } from "node:child_process"; | ||
| import * as fs from "node:fs"; | ||
| import * as path from "node:path"; |
Collaborator
There was a problem hiding this comment.
Move this script to packages/web-components/scripts.
Comment on lines
+46
to
+53
| [ | ||
| "cem", | ||
| "analyze", | ||
| "--litelement", | ||
| "--outdir", | ||
| distDir, | ||
| globs.map(g => `--globs ${g}`).join(" "), | ||
| ].join(" "), |
Collaborator
There was a problem hiding this comment.
Add --packagejson parameter.
Comment on lines
27
to
30
| const metadataGeneratorPath = path.join( | ||
| workspaceDir, | ||
| "packages/web-components/src", | ||
| "scripts/generate-metadata.ts", | ||
| ); |
Collaborator
There was a problem hiding this comment.
Remove this in favor of pnpm --filter @tapsioss/web-components run gen:metadata.
| const cemGeneratorPath = path.join(workspaceDir, "scripts/generate-cem.ts"); | ||
| const componentTemplatePath = path.join(templatesDir, "component.txt"); | ||
| const cemPath = path.join(workspaceDir, "dist/custom-elements.json"); | ||
| const metadataPath = path.join(workspaceDir, "dist/components-metadata.json"); |
Collaborator
There was a problem hiding this comment.
This will be:
path.resolve(packageDir, "../web-components/dist/components-metadata.json");
| const { dirname } = getFileMeta(import.meta.url); | ||
|
|
||
| const packageDir = path.resolve(dirname, ".."); | ||
| const workspaceDir = path.resolve(packageDir, "../../"); |
| console.time("generate"); | ||
| const { stdout, stderr } = await asyncExec( | ||
| ["tsx", cemGeneratorPath].join(" "), | ||
| ["tsx", metadataGeneratorPath].join(" "), |
Collaborator
There was a problem hiding this comment.
This will be replaced with pnpm --filter
mimshins
approved these changes
Mar 5, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.